package com.yosaa.back.enums;

public enum Male50mScore {
    EXCELLENT_100(100, 6.7f, 6.6f),
    EXCELLENT_95(95, 6.8f, 6.7f),
    EXCELLENT_90(90, 6.9f, 6.8f),
    GOOD_85(85, 7.0f, 6.9f),
    GOOD_80(80, 7.1f, 7.0f),
    PASS_78(78, 7.3f, 7.2f),
    PASS_76(76, 7.5f, 7.4f),
    PASS_74(74, 7.7f, 7.6f),
    PASS_72(72, 7.9f, 7.8f),
    PASS_70(70, 8.1f, 8.0f),
    PASS_68(68, 8.3f, 8.2f),
    PASS_66(66, 8.5f, 8.4f),
    PASS_64(64, 8.7f, 8.6f),
    PASS_62(62, 8.9f, 8.8f),
    PASS_60(60, 9.1f, 9.0f),
    FAIL_50(50, 9.3f, 9.2f),
    FAIL_40(40, 9.5f, 9.4f),
    FAIL_30(30, 9.7f, 9.6f),
    FAIL_20(20, 9.9f, 9.8f),
    FAIL_10(10, 10.1f, 10.0f);

    private final float score;
    private final float freshmanSophomore; // 大一大二标准
    private final float juniorSenior; // 大三大四标准

    Male50mScore(float score, float freshmanSophomore, float juniorSenior) {
        this.score = score;
        this.freshmanSophomore = freshmanSophomore;
        this.juniorSenior = juniorSenior;
    }

    public float getScore() {
        return score;
    }

    public float getFreshmanSophomore() {
        return freshmanSophomore;
    }

    public float getJuniorSenior() {
        return juniorSenior;
    }

    // 根据成绩和年级计算分数
    public static float calculateScore(float time, String grade) {
        for (Male50mScore standard : Male50mScore.values()) {
            float threshold = grade.equals("大一") || grade.equals("大二")
                    ? standard.getFreshmanSophomore()
                    : standard.getJuniorSenior();
            if (time <= threshold) {
                return standard.getScore();
            }
        }
        return 0; // 默认分数
    }
}